﻿<UserControl x:Class="Moop.UI.Views.ServerView"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
             xmlns:converters="clr-namespace:Moop.UI.Converters"
             xmlns:OlapEntity="clr-namespace:Moop.Common.IFaces.Database;assembly=Moop.Common"
             xmlns:vm="clr-namespace:Moop.DataLayer.Olap.Impl;assembly=Moop.DataLayer.Olap"
             xmlns:diag="clr-namespace:System.Diagnostics;assembly=WindowsBase"
             mc:Ignorable="d"
             d:DesignHeight="600">

    <UserControl.Resources>
        
        <!--Converters-->
        <converters:BoolConverter x:Key="BoolConverter" />
        <converters:BoolToVisibilityConverter x:Key="VisibilityConverter" />
        <converters:FolderConverter x:Key="FolderConverter" />
        <converters:DataBindingDebugConverter x:Key="DataBindingDebugConverter" />

        <!-- data template for CubeDimension instances -->
        <!--<HierarchicalDataTemplate DataType="{x:Type vm:CubeDimension}">

            <HierarchicalDataTemplate.ItemsSource>
                <MultiBinding Converter="{StaticResource FolderConverter}"
                              ConverterParameter="Sets, Attributes, Hierarchies">
                    <Binding Path="Sets" />
                    <Binding Path="Attributes" />
                    <Binding Path="Hierarchies" />
                </MultiBinding>
            </HierarchicalDataTemplate.ItemsSource>

            <TextBlock Text="{Binding Path=Name}" />
            
        </HierarchicalDataTemplate>


        <HierarchicalDataTemplate DataType="{x:Type converters:FolderItem}" ItemsSource="{Binding Path=Items}">
            <StackPanel>
                <TextBlock Text="{Binding Path=Name}" />
            </StackPanel>
        </HierarchicalDataTemplate>

        <HierarchicalDataTemplate DataType="{x:Type vm:CubeDimensionSet}">
            <StackPanel>
                <TextBlock Text="{Binding Path=Name}" ToolTip="{Binding Path=OlapPath}"/>
            </StackPanel>
        </HierarchicalDataTemplate>

        <HierarchicalDataTemplate DataType="{x:Type vm:CubeDimensionAttribute}">
            <StackPanel>
                <TextBlock Text="{Binding Path=Name}" ToolTip="{Binding Path=OlapPath}" />
            </StackPanel>
        </HierarchicalDataTemplate>

        <HierarchicalDataTemplate DataType="{x:Type vm:CubeDimensionHierarchy}">
            <StackPanel>
                <TextBlock Text="{Binding Path=Name}"  ToolTip="{Binding Path=OlapPath}" />
            </StackPanel>
        </HierarchicalDataTemplate>

        
        
        
        <HierarchicalDataTemplate DataType="{x:Type converters:FolderSubItem}"  ItemsSource="{Binding Path=Items}">
            <StackPanel>
                <TextBlock Text="Levels" />
            </StackPanel>
        </HierarchicalDataTemplate>
        
        <HierarchicalDataTemplate DataType="{x:Type vm:CubeDimensionHierarchyLevel}">
            <StackPanel>
                <TextBlock Text="{Binding Path=Name}" ToolTip="{Binding Path=OlapPath}" />
            </StackPanel>
        </HierarchicalDataTemplate>-->

    </UserControl.Resources>


    <Grid IsEnabled="{Binding IsBusy, Converter={StaticResource BoolConverter}}">

        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="*" />
        </Grid.ColumnDefinitions>
        <Grid.RowDefinitions>
            <RowDefinition Height="70*" />
            <RowDefinition Height="Auto" />
            <RowDefinition Height="30*" />
        </Grid.RowDefinitions>

        <StackPanel Orientation="Vertical"
                    Grid.Row="0"
                    Margin="5">

            <StackPanel Orientation="Horizontal"
                        Width="Auto"
                        HorizontalAlignment="Stretch"
                        VerticalAlignment="Top">

                <StackPanel Orientation="Horizontal"
                            Width="Auto"
                            HorizontalAlignment="Stretch">

                    <TextBox x:Name="ServerConnString"
                             Height="20"
                             Width="200"
                             HorizontalAlignment="Stretch"
                             Text="{Binding ServerConnString}"
                             IsEnabled="{Binding IsBusy, Converter={StaticResource BoolConverter}}" />

                    <Button Width="20"
                            Margin="5"
                            Height="20"
                            Command="{Binding SetServerCommand}"
                            IsEnabled="{Binding IsBusy, Converter={StaticResource BoolConverter}}">
                        <StackPanel>
                            <Image Source="/Moop.UI.Assets;component/Images/16/server16.png" />
                        </StackPanel>

                    </Button>

                </StackPanel>

            </StackPanel>

            <!--
                http://stackoverflow.com/questions/717299/wpf-setting-the-width-and-height-as-a-percentage-value
                TODO: Look at this one to replace code behind event with attached property
                http://www.codeproject.com/Articles/363568/Command-binding-with-Events-a-way-from-simple-to-a
         
                MUST LOOOK AT THIS for TreeView MultiBinding: http://www.hardcodet.net/category/net/wpf/wpf-controls/wpf-treeview            
                Also Heirarchical TV: http://blogs.msdn.com/b/mikehillberg/archive/2009/10/30/treeview-and-hierarchicaldatatemplate-step-by-step.aspx            
            -->
            
            <StackPanel x:Name="dimStackPanel"
                        Orientation="Vertical"
                        HorizontalAlignment="Stretch"
                        VerticalAlignment="Top"
                        Margin="0,10,0,0">

                <ComboBox x:Name="cboSelectedCube"
                          Width="Auto"
                          Height="20"
                          HorizontalAlignment="Stretch"
                          ItemsSource="{Binding Cubes}"
                          SelectedValue="{Binding SelectedCubeName}"
                          SelectionChanged="cboSelectedCube_SelectionChanged"
                          IsEnabled="{Binding CubesLoaded}"
                          DisplayMemberPath="Name"
                          SelectedValuePath="Name" />

                <!--<TreeView x:Name="Dims"
                          ItemsSource="{Binding CubeDimensions}"
                          Margin="-5,10"
                          Width="Auto"
                          BorderThickness="0"
                          HorizontalAlignment="Left"
                          Visibility="{Binding IsCubeSelected, Converter={StaticResource VisibilityConverter}}" />-->                
            </StackPanel>

        </StackPanel>


        <GridSplitter x:Name="ServerGridSplitter"
                      Grid.Row="1"
                      Grid.Column="0"
                      HorizontalAlignment="Stretch"
                      VerticalAlignment="Center"
                      ShowsPreview="True"
                      IsTabStop="False"
                      Background="#FFBCBCBC"
                      Height="5" />


        <StackPanel x:Name="Slicers"
                    Grid.Row="2"
                    Grid.Column="0">

            <!--<Label Content="Metadata..."></Label>-->

        </StackPanel>

    </Grid>

</UserControl>

    